using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// 享元工厂类，用于创建和管理享元对象
/// 这里可以添加缓存逻辑来复用已创建的享元对象
/// </summary>
public class ModelFlyweightFactory_1
{
    private Dictionary<string, ModelFlyweight_1> flyweights = new Dictionary<string, ModelFlyweight_1>();

    public ModelFlyweight_1 GetFlyweight(string key, GameObject prefab)
    {
        if (!flyweights.ContainsKey(key))
        {
            // 如果字典中不存在该键，则创建新的享元对象并添加到字典中
            flyweights[key] = new ConcreteModelFlyweight_1(prefab);
        }
        return flyweights[key];
    }
}
